import { DataSource } from 'typeorm'
import UserModel from '../model/userModel.js'
import RoleModel from '../model/roleModel.js'
import MenuModel from '../model/menuModel.js'

export const datasource = await new DataSource({
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: '123456',
  database: 'jwt_auth',
  // 是否将实体同步到数据库
  synchronize: true,
  // 自动加载实体配置， forFeature() 注册的每个实体都自动加载
  autoLoadEntities: true,
  // 指定时区
  timezone: '+08:00',
  entities: [UserModel, RoleModel, MenuModel]
})
